package cn.kgc.ssm.web.service.impl;

import cn.kgc.ssm.web.entity.LogInfo;
import cn.kgc.ssm.web.mapper.LogInfoMapper;
import cn.kgc.ssm.web.response.ResponseResult;
import cn.kgc.ssm.web.service.LogInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 课工场
 * @date 2024/8/5
 * @description
 */
@Service
public class LogInfoServiceImpl implements LogInfoService {
    @Autowired
    private LogInfoMapper logInfoMapper;

    @Override
    public ResponseResult logInfoPage(Integer page, Integer limit, String model, String description) {

        PageHelper.startPage(page, limit);

        List<LogInfo> logInfos = logInfoMapper.selectList(model, description);

        long total = new PageInfo<LogInfo>(logInfos).getTotal();

        return ResponseResult.success().data(logInfos).count(total);
    }

    @Transactional
    @Override
    public ResponseResult deleteLogInfo(List<Integer> ids) {
        logInfoMapper.deleteLogInfos(ids);
        return ResponseResult.success();
    }

    @Override
    public void addLogsInfo(LogInfo logInfo) {
        logInfoMapper.addLogsInfo(logInfo);
    }
}
